<div data-role="content" class="jqm-content">
  <div data-role="controlgroup" data-type="horizontal" style="clear: both">
    <a href="#Rank" data-role="button" id="rank">Rank</a>
    <a href="#Chart" data-role="button" id="chart">Chart</a>
  </div>
  <p class="ajax_content">
  <table data-role="table" id="table-custom-2" data-mode="columntoggle" class="ui-body-d ui-shadow table-stripe ui-responsive" data-column-btn-theme="b" data-column-btn-text="Columns to display..." data-column-popup-theme="a">
    <thead>
      <tr class="ui-bar-d">
        <th data-priority="2">Rank</th>
        <th>Nickname</th>
        <th data-priority="2">Win</th>
        <th data-priority="3"><abbr title="Rotten Tomato Rating">Lost</abbr></th>
        <th data-priority="1">Point</th>
        <th data-priority="1">Money</th>
      </tr>
    </thead>
    <tbody>
      <?php
      foreach ($rank as $key => $val) {
        ?>
        <tr>
          <th><?php echo $key + 1 ?></th>
          <td><?php echo $val['member_name'] ?></td>
          <td><?php echo $val['count_win'] ?></td>
          <td><?php echo $val['count_lost'] ?></td>
          <td><?php echo $val['rank'] ?></td>
          <td class="red"><?php echo Yii::app()->NumberFormatter->format("$ #,##0", $val['money'], "VND"); ?></td>

        </tr>
        <?php
      }
      ?>


    </tbody>
  </table>
</p>
</div><!-- /content -->
<script>
  $(document).ready(function(){
    $('#chart').click(function(){
      $.post('<?php echo Yii::app()->createUrl('intro/chart'); ?>',function(res){
        $('.ajax_content').html(res);
        $('#table-custom-2, .ui-table-columntoggle-btn').remove();
      });
    });
    $('#rank').click(function(){
      $.post('<?php echo Yii::app()->createUrl('intro/rankAjax'); ?>',function(res){
        $('.ajax_content').html(res);
      });
    });
  });
</script>